package com.woorigil.social.domain.qna;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woorigil.social.domain.ProviderCode;
import com.woorigil.social.domain.ProviderUtils;
import com.woorigil.social.domain.qna.parser.QnaParser;
import com.woorigil.social.domain.qna.parser.QnaParserFactory;

@Service
public class QnaFindService {
	@Autowired QnaParserFactory factory;
	
//	 @Cacheable(cacheName = "qnaListCache")
	public QnaList findQna(String sid, int dealId, ProviderCode providerCode, String metaId) {
		List<QnaBox> qnaBoxList = new ArrayList<QnaBox>();

		try {
			QnaParser parser = factory.get(providerCode);
			qnaBoxList = parser.parse(ProviderUtils.getQnaPage(providerCode, metaId));
		} catch (Exception e) {
			System.out.println(getClass() + " : " + e.getMessage());
		}
		return new QnaList(ProviderCode.CP, qnaBoxList);
	}
}
